// Copyright (c) 2007, Brian Duff

// See LICENSE for full license details.

package org.dubh.jdant;

import java.io.File;
import java.io.IOException;

import java.util.List;


/**
 * Represents a view on a JDeveloper application (jws) file.
 *
 * @author brian.duff@dubh.org
 */
public final class ApplicationFile
{
  private static final String CHILDREN="listOfChildren";
  
  private final ROHashStructure _hash;
  
  public ApplicationFile( File jwsFile ) throws IOException
  {
    _hash = load( jwsFile );
  }
  
  private ROHashStructure load( File file ) throws IOException
  {
    return new ROHashStructureIO().load( file );
  }
  
  /**
   * Returns the projects in the application.
   * 
   * @return a list of File instances for projects in this application.
   *    The collection is unmodifiable.
   */
  public List<File> projects()
  {
    return Util.files( _hash, CHILDREN, "URL" );
  }
}
